﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UserLoging.Dtos;
using UserLoging.Models;

namespace UserLoging.Profiles
{
    public class UserProfile:Profile
    {
        public UserProfile()
        {
            CreateMap<UserRegisterDto, User>()
                    .ForMember(
                dest => dest.Permission,
                opt => opt.MapFrom(src => Permission.user)
                ).ForMember(
                dest => dest.CreateTime,
                opt => opt.MapFrom(src => DateTime.UtcNow)
                ).ForMember(
                dest => dest.UserId,
                opt => opt.MapFrom(src => Guid.NewGuid())
                );
            CreateMap<User, UserForFinduserDto>()
                .ForMember(
                desp => desp.Permission,
                opt => opt.MapFrom(src => src.Permission.ToString())
                );
            CreateMap<User, EditUserFindDto>();
            CreateMap<User, UserRolesDto>().ForMember(
                dest => dest.Permission,
                obt => obt.MapFrom(src => src.Permission.ToString())
                );
        }
        
    }
}
